﻿<EditDataFormTemplateSpec 
	xmlns="bb_appfx_editdataformtemplate"
	xmlns:c="bb_appfx_commontypes" 
	ID="9438d55e-3d99-485c-8e5f-5955f552d6f1" 
	Name="TDSM Edit Data Form"
	Description="Edits a TDSM Org Threshold entry" 
	Author="Blackbaud Professional Services"
	DataFormInstanceID="a36e6308-a4ae-478a-9400-09c3df46e6fb" 
	RecordType="Organizational Hierarchy TDSM Threshold"
	c:SecurityUIFolder="TDSM"
	>
	<SPDataForm>
		<LoadImplementation SPName="USR_USP_DATAFORMTEMPLATE_EDITLOAD_TDSM_ORG_THRESHOLD">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_EDITLOAD_TDSM_ORG_THRESHOLD(
  @ID uniqueidentifier
 ,@BUSINESSUNITCODEID uniqueidentifier = null output
 ,@DATALOADED bit = 0 output
 ,@TSLONG bigint = 0 output
 ,@THRESHOLD money = null output
)
as
set nocount on;
set @DATALOADED = 0;
set @TSLONG = 0;

select
  @DATALOADED = 1
 ,@TSLONG = THRESH.TSLONG
 ,@THRESHOLD = THRESH.THRESHOLD
 ,@BUSINESSUNITCODEID = THRESH.ID
from
  dbo.USR_BUSINESSUNITCODE THRESH
where THRESH.ID = @ID;
return 0;
]]>
			</c:CreateProcedureSQL>
		</LoadImplementation>

		<SaveImplementation SPName="USR_USP_DATAFORMTEMPLATE_EDIT_TDSM_ORG_THRESHOLD">
			<c:CreateProcedureSQL>
				<![CDATA[
create procedure dbo.USR_USP_DATAFORMTEMPLATE_EDIT_TDSM_ORG_THRESHOLD(
  @ID uniqueidentifier
 ,@BUSINESSUNITCODEID uniqueidentifier
 ,@CHANGEAGENTID uniqueidentifier = null
 ,@THRESHOLD money
)
as

set nocount on;
if @CHANGEAGENTID is null begin
  exec dbo.USP_CHANGEAGENT_GETORCREATECHANGEAGENT @CHANGEAGENTID output;
end;

begin try
  update dbo.USR_BUSINESSUNITCODE
  set
    THRESHOLD = @THRESHOLD
   ,CHANGEDBYID = @CHANGEAGENTID
   ,DATECHANGED = GETDATE()
  where ID = @BUSINESSUNITCODEID;
end try
begin catch
  exec dbo.USP_RAISE_ERROR
  return 1
end catch
return 0;
]]>
			</c:CreateProcedureSQL>
		</SaveImplementation>

	</SPDataForm>

    <c:FormMetaData FixedDialog="true">
		<c:FormFields>
            <c:FormField FieldID="BUSINESSUNITCODEID" DataType="Guid" Caption="Business unit" CaptionResourceKey="$$business_unit">
                <c:CodeTable CodeTableName="BUSINESSUNITCODE" />
            </c:FormField>
            <c:FormField FieldID="THRESHOLD" Caption="Minimum threshold" DataType="Money"/>
		</c:FormFields>
	</c:FormMetaData>
</EditDataFormTemplateSpec>